package cn.edu.nchu.controller;

import cn.edu.nchu.entity.CommonResult;
import cn.edu.nchu.entity.ProductModel;
import cn.edu.nchu.service.ProductModelService;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class ProductController {
    @Autowired
    private ProductModelService productModelService;

    @GetMapping("/product_model/search/{productId}")
    public CommonResult<ProductModel> search(@PathVariable String productId){
        ProductModel result = productModelService.findByProductId(productId);
        if (result != null) {
            return new CommonResult<>(200, "查询成功！", result);
        }
        return new CommonResult<>(300, "查询失败！", result);
    }

//    @PostMapping("/product_model/create")
//    public CommonResult<ProductModel> create(@RequestBody JSONObject jsonObject){
//
//    }
}
